/**
 * 匠言知识付费v2.0.0
 * Author: 山西匠言网络科技有限公司
 * 这不是一个免费软件，它受限于许可条款，你可以访问https://www.zsfzxkc.cn/获取更多详细信息。
 * This is not a free software, it under the license terms, you can visit https://www.zsffzxkc.cn/ get more details.
 */
<template>
	<view class="container">
		
		<!-- 没有任何订单图片 -->
		<view id="nodata" v-if="noData == true">
			<image src="../../static/wudingdan.png" mode="aspectFit"></image>
		</view>
		
		<!-- 超级拼团 -->
		<view class="pintuan">
			<view class="pintuan-list" v-for="(item, index) in ptInfo" :key="index" @click="navigate(item.goodstype,item.goodsid)">
				<image class="item-left" :src="item.goodsinfo.thumb" mode=""></image>
				<view class="item-right">
					<text>{{item.goodsname}}</text>
					<view class="pt-jia">
						<text>拼团价：￥{{item.price}}</text>
						<text>包邮</text>
					</view>
					<text>单购价：￥{{item.goodsinfo.price}}</text>
					<view class="money">
						<text>{{item.people}}人团</text>
						<text>马上拼</text>
					</view>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	import { getPintuan } from '@/request/pintuan.js'
	export default {
		data() {
			return {
				ptInfo: [], // 拼团信息列表
				HOST_URL: uni.HOST_URL,
				noData: false
			};
		},
		onShareAppMessage(res) {
			let path = getCurrentPages()
			let path_share = path[0].$page.fullPath
			let path_title = path[0].data.title
			let userinfo = uni.getStorageSync('userinfo')
			let base_set = uni.getStorageSync('base_set')
			if(userinfo.uid=='' || !userinfo.uid){
				uni.navigateTo({
					url:'../login/login'
				})
				return {
					title: '请先登录后再分享给好友',
					path: ''
				}
			}else{
				if (res.from === 'button') {
					
				}
				return {
					title: base_set.title,
					path: `${path_share}?pid=${userinfo.uid}`
				}
			}
		},
		onLoad() {
			// 获取拼团信息
			getPintuan().then(res => {
				console.log(res.data)
				this.ptInfo = res.data.data
				if(this.ptInfo) {
					this.ptInfo.forEach(item => {
						var thumb = item.goodsinfo.thumb.split(',')
						item.goodsinfo.thumb = thumb[0]
					})
				} else {
					this.noData = true
				}
			})
		},
		methods:{
			navigate(goodstype,goodsid){
				console.log(goodstype,goodsid)
				var e,path,action;
				if(goodstype=='course'){
					e='course-details'
					uni.navigateTo({
						url: `/pages/${e}/${e}?menuid=${goodsid}&action=pintuan`
					});
				}else{
					if(goodstype=='mall'){
						e='shop-details'
						path='/pages/mall/'
						action='pintuan'
					}else if(goodstype=='pxb'){
						e='agency-course-details'
						path='/pages/sub/'
					}
					console.log(action)
					uni.navigateTo({
						url: path+`${e}/${e}?id=${goodsid}&action=${action}`
					});
				}
			},
		}
	}
</script>

<style lang="less" scoped>

#nodata {
	width: 100%;
	height: 100vh;
	background-color: #fff;
	image {
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -70%);
	}
}


.pintuan {
	&-list {
		padding: 30upx;
		background-color: #fff;
		margin-bottom: 20upx;
		display: flex;
		align-items: center;
		.item-left {
			width: 194upx;
			height: 170upx;
			border-radius: 20upx;
		}
		.item-right {
			flex: 1;
			margin-left: 30upx;
			display: flex;
			flex-direction: column;
			text:nth-child(1) {
				font-size: 32upx;
				color: #333;
				font-weight: 700;
			}
			.pt-jia {
				margin: 10upx 0;
				display: flex;
				align-items: center;
				text:nth-child(1) {
					font-size: 30upx;
					color: red;
					font-weight: 400;
				}
				text:nth-child(2) {
					width: 80upx;
					height: 40upx;
					border: 2upx solid red;
					box-sizing: border-box;
					font-size: 28upx;
					margin-left: 20upx;
					display: flex;
					justify-content: center;
					align-items: center;
				}
			}
			text:nth-child(3) {
				font-size: 26upx;
				color: #909090;
			}
			.money {
				display: flex;
				justify-content: space-between;
				align-items: center;
				text:nth-child(1) {
					font-size: 26upx;
					color: #808080;
					font-weight: 400;
				}
				text:nth-child(2) {
					display: block;
					width: 150upx;
					height: 60upx;
					background-color: red;
					border-radius: 60upx;
					font-size: 28upx;
					color: #fff;
					text-align: center;
					line-height: 60upx;
				}
			}
		}
	}
}

</style>


